<template>
	<view class="content">
		<view class="title">鸭鸭卡记录</view>
		<view class="dq">当前鸭鸭卡：<text>{{userInfo.source}}</text></view>
		<view class="list">
			<view class="item" v-for=" i in list">
				<view>{{i.title}}</view>
				<view>{{i.source}}</view>
				<view>{{i.created_at}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getAction
	} from '../../../common/request'
	export default {
		data() {
			return {
				list: [],
				current: 1,
				finash: false,
				userInfo:{}
			}
		},
		onLoad() {
			this.reload()
			this.getUserInfo()
		},
		onReachBottom() {
			this.current++
			this.getList()
		},
		methods: {
			getUserInfo() {
				getAction('/user').then(res => {
					this.userInfo = res.data

				})
			},
			reload() {
				this.current = 1
				this.list = []
				this.finash = false
				this.getList()
			},
			getList() {
				if (this.finash) return
				uni.showLoading({
					mask: true
				})
				getAction('/user/source', {
					page: this.current,
					pageSize: 10
				}).then(res => {
					uni.hideLoading()
					this.list = this.list.concat(res.data.data)
					this.finash = res.data.last_page == res.data.current_page
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 30rpx;
		box-sizing: border-box;

		.title {
			padding-left: 30rpx;
			height: 48rpx;
			font-size: 40rpx;
			font-family: PingFangSC-Semibold, PingFangSC-Semibold;
			font-weight: 400;
			color: #2B2B2B;
			line-height: 48rpx;
			margin-bottom: 30rpx;
		}

		.dq {
			padding-left: 30rpx;
			font-size: 28rpx;
			color: #8D9093;
			border-bottom: 1px solid rgba(216, 216, 216, 1);
			padding-bottom: 30rpx;

			text {
				color: rgba(246, 13, 13, 1);
			}
		}

		.list {
			.item {
				min-height: 120rpx;
				border-radius: 10rpx 10rpx 10rpx 10rpx;
				opacity: 1;
				padding: 24rpx 32rpx;
				color: #2B2B2B;
				position: relative;
				border-bottom: 1px solid rgba(216, 216, 216, 1);
				padding-bottom: 60rpx;
				padding-top: 50rpx;

				>view:nth-of-type(1) {

					font-size: 28rpx;
					padding-right: 20rpx;
				}

				>view:nth-of-type(2) {
					position: absolute;
					top: 54rpx;
					right: 20rpx;
					font-size: 24rpx;
					color: rgba(246, 13, 13, 1);

				}

				>view:nth-of-type(3) {

					color: rgba(141, 144, 147, 1);
					font-size: 28rpx;
					line-height: 34rpx;
					margin-top: 10rpx;
					position: absolute;
					bottom: 20rpx;
				}
			}
		}
	}
</style>